import unittest
from selenium import webdriver
from Page import Page
from Page_dele import Page
from Page_fenye import Page
from selenium.webdriver.common.by import By
import time
from ddt import ddt,file_data
@ddt
class TestCase(unittest.TestCase):
    def setUp(self):
        self.driver=webdriver.Firefox()

    def tearDown(self):
        time.sleep(10)
        self.driver.quit()

    @file_data('a.json')
    def test_01_login_search(self):
        po=Page(self.driver)
        po.login()
        duanyan_loc = {By.XPATH,'/html/body/div[1]/div[1]/div[5]/div[1]/div[3]/div/div[1]/div/table/tbody/tr[1]/td[3]/div'}
        self.assertIn('小张',duanyan_loc)

    def test_02_login_dele(self):
        po=Page(self.driver)
        po.login()
        duanyan_loc = {By.XPATH,'/html/body/div[1]/div[1]/div[5]/div[1]/div[3]/div/div[1]/div/table/tbody/tr[1]/td[3]/div'}
        self.assertIn('删除成功', duanyan_loc)

    def test_03_login_fenye(self):
        po = Page(self.driver)
        po.login()
        duanyan_loc = {By.XPATH,'/html/body/div[1]/div[1]/div[5]/div[1]/div[3]/div/div[1]/div/table/tbody/tr[1]/td[3]/div'}
        self.assertIn('添加', duanyan_loc)